<template>
	<view class="page">
		<view class="searchBox">
			<view class="inputBox">
				<view class="inputRow" style="" v-if="isAll==1">
					<view class="label">
						姓名:
					</view>
					<view class="val">
						<u-input v-model="params.name" placeholder="请输入"></u-input>
					</view>
				</view>
				<view class="inputRow">
					<view class="label">
						{{language.checkingInDetail.label1}}:
					</view>
					<view :class="params.workDate_begin ? 'val' : 'emty'" @click="workDate_beginShow=true">
						{{params.workDate_begin ? params.workDate_begin : language.checkingInDetail.tip1 }}
					</view>
				</view>
				<view class="inputRow">
						<view class="label">
							{{language.checkingInDetail.label2}}:
						</view>
						<view :class="params.workDate_end ? 'val' : 'emty'" @click="workDate_endShow=true">
							{{params.workDate_end ? params.workDate_end : language.checkingInDetail.tip1 }}
						</view>
				</view>
			</view>
			<view class="btnBox">
				<view class="btn"  @click="goSearch">
					{{language.checkingInDetail.submit}}
				</view>
			</view>
			
		</view>
		
			<scrollYBox styleText="height: calc( 100vh - 240rpx );" @scrolltolower="scrolltolower" :list="list">
						<template>
							<view style="padding-bottom: 50rpx;">
								<view class="boxItem" v-for="(item,index) in list" :key="index">
									<view class="row flex" v-if="isAll==1">
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label15}}
											</view>
											<view class="val">
												{{item.name | emptyStr }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label16}}
											</view>
											<view class="val">
												{{item.code | emptyStr }}
											</view>
										</view>
									</view>
									
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label3}}
											</view>
											<view class="val">
												{{item.workDate | emptyStr }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label4}}
											</view>
											<view class="val">
												{{item.workMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label5}}
											</view>
											<view class="val">
												{{item.belateMins  }}
											</view>
										</view>
									</view>
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label6}}
											</view>
											<view class="val">
												{{item.earlyMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label7}}
											</view>
											<view class="val">
												{{item.absentMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label8}}
											</view>
											<view class="val">
												{{item.lateMins  }}
											</view>
										</view>
									</view>
									<view class="row flex">
										<!-- <view class="item ">
											<view class="label">
												年休时长
											</view>
											<view class="val">
												{{item.  }}
											</view>
										</view> -->
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label9}}
											</view>
											<view class="val">
												{{item.clMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label10}}
											</view>
											<view class="val">
												{{item.overMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label11}}
											</view>
											<view class="val">
												{{item.weOverMins  }}
											</view>
										</view>
									</view>
									<view class="row flex">
										
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label12}}
											</view>
											<view class="val">
												{{item.holidayOverMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label13}}
											</view>
											<view class="val">
												{{item.businessMins  }}
											</view>
										</view>
										<view class="item ">
											<view class="label">
												{{language.checkingInDetail.label14}}
											</view>
											<view class="val">
												{{item.ifRestDay=='0'?'否':'是' }}
											</view>
										</view>
										
									</view>
									<view class="row flex">
										
									</view>
								</view>
							</view>
						</template>
					</scrollYBox>
	
		<u-datetime-picker
		    :show="workDate_beginShow" ref="datetimePicker" v-model="workDate_begin" 
		    mode="date"  @cancel="workDate_beginShow=false" @confirm="workDate_beginConfirm"
		       ></u-datetime-picker>
		<u-datetime-picker
			:show="workDate_endShow" ref="datetimePicker" v-model="workDate_end" 
			mode="date"  @cancel="workDate_endShow=false" @confirm="workDate_endConfirm"
	       ></u-datetime-picker>
		<u-picker :show="departShow" ref="uPicker" :columns="departColumns" @cancel="departShow=false" keyName="departName"
		  @confirm="depatConfirm" @change="departChangeHandler"></u-picker>
	</view>
</template>

<script>
	import {attComputeResultListApi,attComputeResultListPersonalApi} from '@/common/api/commonApi/checking.js'
	export default {
		data() {
			return {
				list:[],
				params:{
					workDate_begin : '',
					workDate_end : '',
					pageNo: 1,
					pageSize: 10
				},
				workDate_begin: Number(new Date()),
				workDate_end: Number(new Date()),
				workDate_beginShow : false,
				workDate_endShow : false,
				total : 0,
				selectList : [
					[
						{
							label : 'PC机',
							val: 1
						},
						{
							label : '移动端',
							val: 2
						},
						{
							label : '充值机',
							val: 3
						},
						{
							label : 'P0S',
							val: 4
						},
						
					]
				],
				selectLabel : '',
				total: '',
				selectInfoAccount: uni.getStorageSync('selectInfoAccount'),
				departList:[],
				departColumns: [
					[],[]
				    // ['中国', '美国'],
				    // ['深圳', '厦门', '上海', '拉萨']
				],
				departColumnData: [
					
				    // ['深圳', '厦门', '上海', '拉萨'],
				    // ['得州', '华盛顿', '纽约', '阿拉斯加']
				],
				departShow :false,
				selecetDepart : {},
				isAll: 2,
			}
		},
		components:{
		},
		methods: {
			departChangeHandler(e) {
			    const {
			        columnIndex,
			        value,
			        values, // values为当前变化列的数组内容
			        index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
			        picker = this.$refs.uPicker
			    } = e
			    // 当第一列值发生变化时，变化第二列(后一列)对应的选项
			    if (columnIndex === 0) {
			        // picker为选择器this实例，变化第二列对应的选项
			        picker.setColumnValues(1, this.departColumnData[index])
			    }
			},
			// 回调参数为包含columnIndex、value、values
			depatConfirm(e) {
			    console.log('confirm', e)
				this.selecetDepart = e.value[e.value.length-1]
			    this.departShow = false
			},
			handleDetail(item){
				this.goPage('/pages/componentsC/safe/accessRecordDetail',{id:1})
			},
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.pageNo ++
				this.getList()
			},
			goSearch(){
				if(this.params.workDate_begin && this.params.workDate_end ){
					if(new Date(this.params.workDate_begin) > new Date(this.params.workDate_end) ) return this.setMessage('开始时间不能大于结束时间')
				}
				this.params.pageNo = 1 
				this.getList()
			},
			workDate_beginConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.workDate_begin = date
				console.log(this.params.workDate_begin);
				this.workDate_beginShow = false
			},
			workDate_endConfirm(e){
				let date = this.dateformat(e.value).split(' ')[0]
				this.params.workDate_end = date
				this.workDate_endShow = false
			},
			getList(){
				let params = this.params
				if(this.isAll==2){
					params.personId = this.selectInfoAccount.id
					attComputeResultListPersonalApi(params).then(res=>{
						if(params.pageNo==1) this.list = []
						this.list = this.list.concat(res.result.records)
						this.total = res.result.total
					})
				}else{
					attComputeResultListApi(params).then(res=>{
						if(params.pageNo==1) this.list = []
						this.list = this.list.concat(res.result.records)
						this.total = res.result.total
					})
				}
				
			},
			
		},
		onLoad({isAll}) {
			this.setPageTitle(this.language.checkingInDetail.title)
			if(isAll) this.isAll = isAll
			this.params.workDate_begin = this.getMonthFirst()
			this.params.workDate_end =this.dateformat(new Date()).split(' ')[0]
			
			this.getList()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f1f1f1;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.boxItem{
			background-color: #fff;
			margin: 20rpx;
			border-radius: 8rpx;
			padding: 10rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(102,102,102,0.15);
			.row{
				margin: 10rpx;
				display: flex;
				.item{
					width: 50%;
					// flex: 1;
				}
				.label{
					color: #969696;
				}
				.val{
					color: #353535;
					font-size: 32rpx;
				}
				.btn{
						padding: 0 30rpx;
						width: 120rpx;
						height: 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						background: #1890ff;
						border-radius: 8rpx;
						color: #fff;
				}
			}
		}
		
}
</style>
